package com.kaifamiao.demo.d0815;

import java.util.Comparator;
import java.util.TreeMap;

public class TreeMapDemo {

    public static void main(String[] args) {
        Comparator comparator = new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge() - o2.getAge();
            }
        };

//        TreeMap treeMap = new TreeMap(comparator);

        TreeMap treeMap = new TreeMap();
        treeMap.put(5, "E");
        treeMap.put(3, "C");
        treeMap.put(1, "A");

//        treeMap.put(new Student("慢羊羊", 35), "C");
//        treeMap.put(new Student("喜羊羊", 19), "A");
//        treeMap.put(new Student("灰太狼", 30), "B");


        System.out.println(treeMap);

        System.out.println(treeMap.firstKey());
        System.out.println(treeMap.firstEntry());
    }

}
